package com.stylefeng.guns.modular.manager.service.impl;

import com.baomidou.mybatisplus.mapper.Wrapper;
import com.stylefeng.guns.core.datascope.DataScope;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.modular.system.model.ManagerCustomer;
import com.stylefeng.guns.modular.system.dao.ManagerCustomerMapper;
import com.stylefeng.guns.modular.manager.service.IManagerCustomerService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LiuXin
 * @since 2018-09-12
 */
@Service
public class ManagerCustomerServiceImpl extends ServiceImpl<ManagerCustomerMapper, ManagerCustomer> implements IManagerCustomerService {

    @Override
    public List<ManagerCustomer> selectList(Wrapper<ManagerCustomer> wrapper) {
        if(ShiroKit.isAdmin()){
            List<ManagerCustomer> result = this.baseMapper.selectList(wrapper);
            return result;
        }else {
            DataScope dataScope = new DataScope(ShiroKit.getDeptDataScope());
            ManagerCustomer managerCustomer = wrapper.getEntity() ==null ? new ManagerCustomer():wrapper.getEntity();
            List<ManagerCustomer> result = this.baseMapper.listDataScope(dataScope,managerCustomer);
            return result;
        }
    }
}
